package com.rem.designPattern.builder建造者;

/**
 * @author Rem
 * @date 2022-11-16
 */
public interface HouseBuilder {

    void piling();

    void walling();

    void roofed();

    House getHouse();
}

/**
 * 普通房子
 */
class NormalRoomBuilder implements HouseBuilder {
    private final House normalRoom = new House();

    @Override
    public void piling() {
        normalRoom.setPile("5m地基");
        System.out.println("普通房打地基...");
    }

    @Override
    public void walling() {
        normalRoom.setWall("10cm外墙");
        System.out.println("普通房砌墙...");
    }

    @Override
    public void roofed() {
        normalRoom.setRoof("石棉瓦屋顶");
        System.out.println("普通房封顶...");
    }

    @Override
    public House getHouse() {
        return normalRoom;
    }
}

/**
 * 别墅
 */
class VillaBuilder implements HouseBuilder {
    private final House villa = new House();

    @Override
    public void piling() {
        villa.setPile("30m地基");
        System.out.println("别墅打地基...");
    }

    @Override
    public void walling() {
        villa.setWall("50cm外墙");
        System.out.println("别墅砌墙...");
    }

    @Override
    public void roofed() {
        villa.setRoof("琉璃瓦屋顶");
        System.out.println("别墅封顶...");
    }

    @Override
    public House getHouse() {
        return villa;
    }
}
